import { IPSAppCodeList } from '../../app/codelist/ipsapp-code-list';
import { IPSAppDEField } from '../../app/dataentity/ipsapp-defield';
import { IPSAppView } from '../../app/view/ipsapp-view';
import { IPSEditor } from '../ipseditor';
import { IPSDEGrid } from './ipsdegrid';
import { IPSDEGridEditItem } from './ipsdegrid-edit-item';
import { IPSDEGridEditItemUpdate } from './ipsdegrid-edit-item-update';
import { IPSDEGridFieldColumn } from './ipsdegrid-field-column';
import { PSDEGridColumnImpl } from './psdegrid-column-impl';
import { IPSDEUIAction } from '../../dataentity/uiaction/ipsdeuiaction';

export class PSDEGridFieldColumnImpl extends PSDEGridColumnImpl implements IPSDEGridFieldColumn, IPSDEGridEditItem {
  get cLConvertMode(): 'NONE' | 'FRONT' | 'BACKEND' {
    return this.M.cLConvertMode;
  }

  get createDV(): string {
    return this.M.createDV;
  }

  get createDVT(): 'SESSION' | 'APPLICATION' | 'UNIQUEID' | 'CONTEXT' | 'PARAM' | 'OPERATOR' | 'OPERATORNAME' | 'CURTIME' | 'APPDATA' {
    return this.M.createDVT;
  }

  get dataItemName(): string {
    return this.M.dataItemName;
  }

  get enableCond(): 0 | 1 | 2 | 3 {
    return this.M.enableCond;
  }

  get excelCaption(): string {
    return this.M.excelCaption;
  }

  protected filterpseditor: IPSEditor | null = null;

  getFilterPSEditor(): IPSEditor | null {
    if (this.filterpseditor != null) return this.filterpseditor;
    const value = this.M.getFilterPSEditor;
    if (value == null) {
      return null;
    }
    this.filterpseditor = this.getPSModel4('control.IPSEditor', value, 'getFilterPSEditor') as IPSEditor;
    return this.filterpseditor;
  }

  get filterPSEditor(): IPSEditor | null {
    return this.getFilterPSEditor();
  }

  getFilterPSEditorMust(): IPSEditor {
    const value = this.getFilterPSEditor();
    if (value == null) {
      throw new Error('未指定过滤器编辑器对象');
    }
    return value;
  }

  get groupItem(): string {
    return this.M.groupItem;
  }

  get ignoreInput(): 0 | 1 | 2 | 3 {
    return this.M.ignoreInput;
  }

  protected linkpsappview: IPSAppView | null = null;

  getLinkPSAppView(): IPSAppView | null {
    if (this.linkpsappview != null) return this.linkpsappview;
    const value = this.M.getLinkPSAppView;
    if (value == null) {
      return null;
    }
    this.linkpsappview = this.getPSModel4('app.view.IPSAppView', value, 'getLinkPSAppView') as IPSAppView;
    return this.linkpsappview;
  }

  get linkPSAppView(): IPSAppView | null {
    return this.getLinkPSAppView();
  }

  getLinkPSAppViewMust(): IPSAppView {
    const value = this.getLinkPSAppView();
    if (value == null) {
      throw new Error('未指定链接视图');
    }
    return value;
  }

  get linkValueItem(): string {
    return this.M.linkValueItem;
  }

  get objectIdField(): string {
    return this.M.objectIdField;
  }

  get objectNameField(): string {
    return this.M.objectNameField;
  }

  get objectValueField(): string {
    return this.M.objectValueField;
  }

  get outputCodeListConfigMode(): 0 | 1 | 2 {
    return this.M.outputCodeListConfigMode != null ? this.M.outputCodeListConfigMode : 0;
  }

  protected psappcodelist: IPSAppCodeList | null = null;

  getPSAppCodeList(): IPSAppCodeList | null {
    if (this.psappcodelist != null) return this.psappcodelist;
    const value = this.M.getPSAppCodeList;
    if (value == null) {
      return null;
    }
    this.psappcodelist = this.getPSModel4('app.codelist.IPSAppCodeList', value, 'getPSAppCodeList') as IPSAppCodeList;
    return this.psappcodelist;
  }

  get psAppCodeList(): IPSAppCodeList | null {
    return this.getPSAppCodeList();
  }

  getPSAppCodeListMust(): IPSAppCodeList {
    const value = this.getPSAppCodeList();
    if (value == null) {
      throw new Error('未指定应用代码表');
    }
    return value;
  }

  protected psappdefield: IPSAppDEField | null = null;

  getPSAppDEField(): IPSAppDEField | null {
    if (this.psappdefield != null) return this.psappdefield;
    const value = this.M.getPSAppDEField;
    if (value == null) {
      return null;
    }
    this.psappdefield = this.getPSModel4('app.dataentity.IPSAppDEField', value, 'getPSAppDEField') as IPSAppDEField;
    return this.psappdefield;
  }

  get psAppDEField(): IPSAppDEField | null {
    return this.getPSAppDEField();
  }

  getPSAppDEFieldMust(): IPSAppDEField {
    const value = this.getPSAppDEField();
    if (value == null) {
      throw new Error('未指定列应用实体属性');
    }
    return value;
  }

  protected psdegridedititemupdate: IPSDEGridEditItemUpdate | null = null;

  getPSDEGridEditItemUpdate(): IPSDEGridEditItemUpdate | null {
    if (this.psdegridedititemupdate != null) return this.psdegridedititemupdate;
    const value = this.M.getPSDEGridEditItemUpdate;
    if (value == null) {
      return null;
    }
    const ipsdegrid = this.getParentPSModelObject('control.grid.IPSDEGrid') as IPSDEGrid;
    if (ipsdegrid != null) {
      this.psdegridedititemupdate = ipsdegrid.findPSDEGridEditItemUpdate(value);
    }
    return this.psdegridedititemupdate;
  }

  get psDEGridEditItemUpdate(): IPSDEGridEditItemUpdate | null {
    return this.getPSDEGridEditItemUpdate();
  }

  getPSDEGridEditItemUpdateMust(): IPSDEGridEditItemUpdate {
    const value = this.getPSDEGridEditItemUpdate();
    if (value == null) {
      throw new Error('未指定表格编辑项更新对象');
    }
    return value;
  }

  protected psdeuiaction: IPSDEUIAction | null = null;

  getPSDEUIAction(): IPSDEUIAction | null {
    if (this.psdeuiaction != null) return this.psdeuiaction;
    const value = this.M.getPSDEUIAction;
    if (value == null) {
      return null;
    }
    this.psdeuiaction = this.getPSModel4('dataentity.uiaction.IPSDEUIAction', value, 'getPSDEUIAction') as IPSDEUIAction;
    return this.psdeuiaction;
  }

  get psDEUIAction(): IPSDEUIAction | null {
    return this.getPSDEUIAction();
  }

  getPSDEUIActionMust(): IPSDEUIAction {
    const value = this.getPSDEUIAction();
    if (value == null) {
      throw new Error('未指定内置界面行为');
    }
    return value;
  }

  protected pseditor: IPSEditor | null = null;

  getPSEditor(): IPSEditor | null {
    if (this.pseditor != null) return this.pseditor;
    const value = this.M.getPSEditor;
    if (value == null) {
      return null;
    }
    this.pseditor = this.getPSModel4('control.IPSEditor', value, 'getPSEditor') as IPSEditor;
    return this.pseditor;
  }

  get psEditor(): IPSEditor | null {
    return this.getPSEditor();
  }

  getPSEditorMust(): IPSEditor {
    const value = this.getPSEditor();
    if (value == null) {
      throw new Error('未指定编辑器对象');
    }
    return value;
  }

  get resetItemName(): string {
    return this.M.resetItemName;
  }

  get textSeparator(): string {
    return this.M.textSeparator;
  }

  get treeColumnMode(): 0 | 1 | 2 | 3 | 8 | 4 | 12 {
    return this.M.treeColumnMode != null ? this.M.treeColumnMode : 0;
  }

  get unitName(): string {
    return this.M.unitName;
  }

  get unitNameWidth(): number {
    return this.M.unitNameWidth != null ? this.M.unitNameWidth : 0;
  }

  get updateDV(): string {
    return this.M.updateDV;
  }

  get updateDVT(): 'SESSION' | 'APPLICATION' | 'UNIQUEID' | 'CONTEXT' | 'PARAM' | 'OPERATOR' | 'OPERATORNAME' | 'CURTIME' | 'APPDATA' {
    return this.M.updateDVT;
  }

  get valueFormat(): string {
    return this.M.valueFormat;
  }

  get valueItemName(): string {
    return this.M.valueItemName;
  }

  get valueSeparator(): string {
    return this.M.valueSeparator;
  }

  get valueType(): 'SIMPLE' | 'SIMPLES' | 'OBJECT' | 'OBJECTS' | 'USER' | 'USER2' {
    return this.M.valueType || 'SIMPLE';
  }

  get allowEmpty(): boolean {
    return this.M.allowEmpty;
  }

  get convertToCodeItemText(): boolean {
    return this.M.convertToCodeItemText != null ? this.M.convertToCodeItemText : false;
  }

  get enableItemPriv(): boolean {
    return this.M.enableItemPriv != null ? this.M.enableItemPriv : false;
  }

  get enableLinkView(): boolean {
    return this.M.enableLinkView != null ? this.M.enableLinkView : false;
  }

  get enableRowEdit(): boolean {
    return this.M.enableRowEdit != null ? this.M.enableRowEdit : false;
  }

  get enableUnitName(): boolean {
    return this.M.enableUnitName != null ? this.M.enableUnitName : false;
  }

  get needCodeListConfig(): boolean {
    return this.M.needCodeListConfig != null ? this.M.needCodeListConfig : false;
  }

  get cls(): string {
    return 'PSDEGridFieldColumnImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'control.grid.IPSDEGridEditItem' || cls == 'control.grid.IPSDEGridFieldColumn') return true;
    return super.instanceof(cls);
  }
}
